﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace FPSO.HMI.Controls.Converter
{
    [ValueConversion(typeof(Visibility), typeof(bool))]
    public class VisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (parameter == null)
            {
                return System.Convert.ToBoolean(value) ? Visibility.Visible : Visibility.Hidden;
            }
            else
            {
                return System.Convert.ToBoolean(value) ? Visibility.Hidden : Visibility.Visible;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is Visibility)
            {
                return (Visibility)value == Visibility.Visible ? true : false;
            }

            return false;
        }
    }
}